package com.qk.management.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qk.common.util.PageResult;
import com.qk.dto.log.LogDto;
import com.qk.management.mapper.LogMapper;
import com.qk.management.service.LogService;
import com.qk.vo.log.LogVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Slf4j
@Service
@SuppressWarnings("all")
@Transactional(rollbackFor = Exception.class)
public class LogServiceImpl extends ServiceImpl<LogMapper, LogDto> implements LogService {
    @Autowired
    private LogMapper logMapper;
    @Override
    public PageResult<LogVo> getLogList(LogDto logDto) {
        PageHelper.startPage(logDto.getPage(), logDto.getPageSize());
        List<LogVo> list = this.baseMapper.getLogList(logDto);
        Page<LogVo> rs = (Page<LogVo>)  list;
        return PageResult.<LogVo>builder()
                .total((int)rs.getTotal())
                .rows(rs)
                .build();

    }
}
